﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRCPhase2Tester.Daemons;
using RoutingDaemon.Backend;

namespace IRCPhase2Tester.Tests
{
    class NodeAcknowledgement : MultiClientsMultiDaemons
    {
        private bool DaemoBackEnd;
        #region ITest Members

        public override string Title()
        {
            return "Node Acknowledgement";
        }

        public override void BuildUp()
        {
            StartNewDaemon(1, Session.Instance.AllConfigurationFiles[1], typeof(ExternalRoutingDaemon));
            StartNewDaemon(2, Session.Instance.AllConfigurationFiles[2], typeof(LocalRoutingDaemon));

            base.BuildUp();
        }

        public override bool RunTest()
        {
            System.Threading.Thread.Sleep(5000);

            int attempts = 5;
            while (attempts-- > 0)
            {
                if (DaemonBackEnd.Instance.GetNodeByID(1).IsAcknowledged)
                    return true;
                System.Threading.Thread.Sleep(10000);
            }

            return false;
        }

        #endregion
    }
}
